﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Blazing.MvcBlog.Classes;

namespace Blazing.MvcBlog
{
    public class GlobalApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add(
                new RegexRoute(@"^archive/(?<postpath>.+)/AddFeedback",
                    new MvcRouteHandler())
                {
                    Defaults = new RouteValueDictionary(
                      new { controller = "Post", action = "AddFeedback" })
                });

            routes.Add(
                new RegexRoute(@"^archive/(?<postpath>.+)",
                    new MvcRouteHandler())
                {
                    Defaults = new RouteValueDictionary(
                      new { controller = "Post", action = "View" })
                });


            routes.Add(
                new RegexRoute(@"(.+)",
                    new MvcRouteHandler())
                    {
                        Defaults = new RouteValueDictionary(
                          new { controller = "Home", action = "Index" })
                    });

        }

        protected void Application_Start()
        {
            ViewEngines.Engines.Add(new NHaml.Web.Mvc.NHamlMvcViewEngine());
            RegisterRoutes(RouteTable.Routes);
        }
    }
}